package route

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

type handler[T any, S any] func(*gin.Context, T) (S, error)

func GET[T any, S any](r register, relativePath string, fn handler[T, S]) {
	create(r, relativePath, http.MethodGet, fn)
}

func POST[T any, S any](r register, relativePath string, fn handler[T, S]) {
	create(r, relativePath, http.MethodPost, fn)
}

func DELETE[T any, S any](r register, relativePath string, fn handler[T, S]) {
	create(r, relativePath, http.MethodDelete, fn)
}

func PATCH[T any, S any](r register, relativePath string, fn handler[T, S]) {
	create(r, relativePath, http.MethodPatch, fn)
}

func PUT[T any, S any](r register, relativePath string, fn handler[T, S]) {
	create(r, relativePath, http.MethodPut, fn)
}

func OPTIONS[T any, S any](r register, relativePath string, fn handler[T, S]) {
	create(r, relativePath, http.MethodOptions, fn)
}

func HEAD[T any, S any](r register, relativePath string, fn handler[T, S]) {
	create(r, relativePath, http.MethodHead, fn)
}
